package cn.trip.service.index;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cn.trip.dao.index.IndexMapper;
import cn.trip.pojo.Trip_address;
import cn.trip.pojo.Trip_bill;
import cn.trip.pojo.Trip_brands;
import cn.trip.pojo.Trip_place;
import cn.trip.pojo.Trip_product;
import cn.trip.pojo.Trip_room;
import cn.trip.pojo.Trip_theme;
import cn.trip.pojo.Trip_tourist;

@Service
public class IndexServiceImpl implements IndexService {

	@Resource
	private IndexMapper indexMapper;
	
	@Override
	public List<Trip_brands> getAllList(int currentPageNo, int pageSize) {
		return indexMapper.getAllList((currentPageNo-1)*pageSize, pageSize);
	}

	@Override
	public int allCount() {
		return indexMapper.allCount();
	}

	@Override
	public int partCount(int p_type) {
		return indexMapper.partCount(p_type);
	}

	@Override
	public List<Trip_product> getAllListByPtype(int p_type,String area,String p_Name,Integer th_id ,int currentPageNo,
			int pageSize) {
		return indexMapper.getAllListByPtype(p_type,area,p_Name, th_id ,(currentPageNo-1)*pageSize, pageSize);
	}

	@Override
	public List<Trip_brands> getBrandsDesc() {
		return indexMapper.getBrandsDesc();
	}

	@Override
	public List<Trip_brands> getBrands(String area, String desc, String title,
			int currentPageNo, int pageSize) {
		return indexMapper.getBrands(area, desc, title, (currentPageNo-1)*pageSize, pageSize);
	}

	@Override
	public Trip_brands getBrandById(int id) {
		return indexMapper.getBrandById(id);
	}

	@Override
	public List<Trip_address> getAddress() {
		return indexMapper.getAddress();
	}

	@Override
	public Trip_brands getBrandsByAreaOrUsingDate(Date usingDate, String title) {
		return indexMapper.getBrandsByAreaOrUsingDate(usingDate, title);
	}

	@Override
	public boolean add(String p_Name, Date usingDate, double price, int count,
			double totalPrice, Date createDate, int u_id, int status,
			int isPay, String phone, String contact, int proType,
			String userCode,String b_Code,String org_pic,String p_createBy) {
		System.out.println(123);
		boolean flag = false;
		if(indexMapper.add(p_Name, usingDate, price, count, totalPrice, createDate, u_id, status, isPay, phone, contact, proType, userCode,b_Code,org_pic,p_createBy)>0){
			flag = true;
		}
		return flag;
	}

	@Override
	public boolean addTourist(Trip_tourist tourist) {
		boolean flag = false;
		if(indexMapper.addTourist(tourist)>0){
			flag = true;
		}
		return flag;
	}

	@Override
	public Trip_bill getBill_Id(String b_Code) {
		return indexMapper.getBill_Id(b_Code);
	}

	@Override
	public List<Trip_place> getPlaces() {
		return indexMapper.getPlaces();
	}

	@Override
	public int getPlaceCount(int p_Type,String area,String p_Name,int th_id) {
		return indexMapper.getPlaceCount(p_Type,area,p_Name,th_id);
	}

	@Override
	public Trip_product geTrip_product(int id) {
		return indexMapper.geTrip_product(id);
	}

	@Override
	public Trip_room getTrip_rooms(String hotelName,String roomName,Date usingDate) {
		return indexMapper.getTrip_rooms(hotelName,roomName,usingDate);
	}

	@Override
	public boolean modifyRoomRest(int rest, int room_id) {
		boolean flag = false;
		if(indexMapper.modifyRoomRest(room_id, rest)>0){
			flag = true;
		}
		return flag;
	}

	@Override
	public boolean addHotelBill(String p_Name, Date usingDate, double price,
			int count, double totalPrice, Date createDate, int u_id,
			int status, int roomType, int isPay, String phone, String contact,
			int proType, String userCode, String b_Code,String org_pic,String p_createBy) {
		boolean flag = false;
		if(indexMapper.addHotelBill(p_Name, usingDate, price, count, totalPrice, createDate, roomType, u_id, status, isPay, phone, contact, proType, userCode, b_Code,org_pic,p_createBy)>0){
			flag = true;
		}
		return flag;
	}

	@Override
	public Trip_room getRoom_id(int room_id) {
		return indexMapper.getRoom_id(room_id);
	}

	@Override
	public List<Trip_theme> getThemes(int theme_id) {
		return indexMapper.getThemes(theme_id);
	}

}
